<template>
  <div>
    <div>
      <a-row type="flex" justify="space-between" align="middle">
        <div class="">
          <a-input
            class="search-input"
            v-model="model.queryIp"
            placeholder="文件名称"
            allow-clear
            style="width: 190px"
          />
          <a-select
            v-model="model.result"
            placeholder="病毒类型"
            class="search-input"
            allowClear
          >
            <a-select-option
              v-for="item in virus"
              :key="item.value"
              :value="item.value"
              >{{ item.label }}</a-select-option
            >
          </a-select>

          <a-button
            type="primary"
            @click="
              current = 1;
              search();
            "
            >查询
          </a-button>
        </div>
      </a-row>
    </div>
    <a-table
      :columns="columns"
      :data-source="data"
      size="small"
      :pagination="false"
      :loading="loading"
      style="margin-top: 10px"
      rowKey="index"
    >
      <template slot="action" slot-scope="text, record">
        <span class="button-text" @click="visible = true">查看详情</span>
      </template>
    </a-table>
    <Pagination
      :total="total"
      :defaultPage="page"
      :defaultCurrent="current"
      @sizeChange="
        (val) => {
          page = val;
          current = 1;
          search();
        }
      "
      @currentChange="currentChange"
    />
    <a-modal
      title="查看详情"
      :maskClosable="false"
      :keyboard="false"
      :visible="visible"
      :footer="null"
      centered
      :width="960"
      @cancel="visible = false"
    >
      <a-alert message="该可执行文件已被签名" type="info" show-icon />

      <a-alert
        message="可执行文件的段中包含位置的PE节点，可能是误报(3 events)"
        type="info"
        show-icon
      />
      <a-alert
        message="分配了读-写-执行权限的内存(通常情况下白己解压缩)(1 event)"
        type="warning"
        show-icon
      />
      <a-alert
        message="PE的资源文件中发现了非本地语言(2 events)"
        type="warning"
        show-icon
      />
      <a-alert
        message="以创建或修改注册表的方式达到windows开机白启动项的方式安装白己 (1 event)"
        type="error"
        show-icon
      />
      <a-row style="margin: 8px 0">
        <a-col :span="5"> service name </a-col>
        <a-col :span="5">FRundll</a-col>
        <a-col :span="5">service path</a-col>
        <a-col :span="9">C:\\Wndowesvsteme2usRundllleye .Netcat</a-col>
      </a-row>
      <a-alert
        message="创建了一个未启动的service服务(1 event)"
        type="error"
        show-icon
      />
      <a-table
        :columns="modalColumns"
        :data-source="modalData"
        size="small"
        :pagination="false"
        style="margin-top: 10px"
        rowKey="index"
      >
        <template slot="time" slot-scope="text, record">
          <a-row v-for="(item, index) in record.time" :key="index">
            <a-col :span="24">{{ item }}</a-col>
          </a-row>
        </template>
        <template slot="arguments" slot-scope="text, record">
          <div>
            <a-row v-for="(item, index) in record.arguments" :key="index">
              <a-col :span="24">{{ item }}</a-col>
            </a-row>
          </div>
        </template>
      </a-table>
      <div class="flex flex-end mt-10">
        <u-button
          class="ml-10 btn-default btn-confirm"
          @click="visible = false"
        >
          关闭
        </u-button>
      </div>
    </a-modal>
  </div>
</template>

<script>
const columns = [
  {
    title: "编号",
    key: "no",
    dataIndex: "no",
  },
  {
    title: "文件",
    key: "fileName",
    dataIndex: "fileName",
  },
  {
    title: "描述",
    key: "desc",
    dataIndex: "desc",
  },
  {
    title: "优先级",
    key: "priority",
    dataIndex: "priority",
  },
  {
    title: "时间",
    key: "time",
    dataIndex: "time",
  },
  {
    title: "风险等级",
    key: "riskLevel",
    dataIndex: "riskLevel",
  },

  {
    title: "文本类型",
    key: "fileType",
    dataIndex: "fileType",
  },
  {
    title: "样本类型",
    key: "sampleType",
    dataIndex: "sampleType",
  },
  {
    title: "文件哈希值",
    key: "fileHash",
    dataIndex: "fileHash",
  },
  {
    title: "静态扫描",
    key: "staticScan",
    dataIndex: "staticScan",
  },
  {
    title: "操作",
    key: "action",
    scopedSlots: { customRender: "action" },
  },
];

import Pagination from "@/components/Pagination.vue";
import { mockSample } from "@/config/code/data/sample";

export default {
  components: {
    Pagination,
  },
  data() {
    return {
      columns,
      loading: false,
      data: mockSample,
      page: 10,
      current: 1,
      total: 5,
      model: {
        queryIp: "",
        time: undefined,
        result: undefined,
        queryBeginTime: "",
        queryEndTime: "",
      },
      visible: false,
      virus: [
        {
          label: "非病毒",
          value: "非病毒",
        },
        {
          label: "病毒",
          value: "病毒",
        },
      ],
      modalColumns: [
        {
          title: "Time& API",
          key: "time",
          scopedSlots: { customRender: "time" },
        },
        {
          title: "Arguments",
          key: "arguments",
          scopedSlots: { customRender: "arguments" },
        },
        {
          title: "Status",
          key: "status",
          dataIndex: "status",
        },
        {
          title: "Return",
          key: "return",
          dataIndex: "return",
        },
      ],
      modalData: [
        {
          time: ["CreateServiceA", "Nov. 8, 2023,11:02 a.m."],
          arguments: [
            "service start name:",
            "start type: 2",
            "password:",
            "display_name: Windows Rwxf",
            "filepath: C:\\windows\\Systen32\\FRund111.exe -NetSata",
            "service_ name: FRund111",
            "filepath r. C:Wwindows\\system32\\FRund111.exe -NetSata",
            "desired access: 983551",
            "service handle: 0x006225c8",
            "error control: ",
            "service type: 272",
            "service manager handle: 0x00622578",
          ],
          status: "1",
          return: "6432200",
        },
      ],
    };
  },
  methods: {
    onChange(e) {
      console.log(e);
      if (e[0]) {
        this.model.queryBeginTime = e[0];
        this.model.queryEndTime = e[1];
      } else {
        this.model.queryBeginTime = "";
        this.model.queryEndTime = "";
      }
    },
    currentChange(val) {
      this.current = val;
      this.search();
    },
    search() {
      console.log(this.model);
    },
  },
};
</script>
